import psycopg2
import psycopg2.extras
import sys
from shapely.geometry import box
from shapely.wkt import dumps, loads
import gdal
from gdalconst import *
import os
import constant


if __name__ == '__main__':
	resx=0.117292465957718
	resy=-0.117292465957718
	#merge_command = "python gdal_merge.py -o /home/phamha/Desktop/dem_10km.tif -ot Int16 -n 0 -a_nodata 0"
	merge_command = "python gdal_merge.py -o /home/phamha/Desktop/dem_10km_full.tif"
	merge_command += " /home/phamha/Desktop/out12_10km.tif /home/phamha/Desktop/out34_10km.tif /home/phamha/Desktop/out56_10km.tif /home/phamha/Desktop/out789_10km.tif"
	#print(merge_command)
	#os.system(merge_command)

	
	regrid_command = "gdalwarp -s_srs '+proj=longlat +datum=WGS84' -t_srs '+proj=longlat +datum=WGS84' -ot Int16 -wt Int16 -te 102.144996643067 8.56333160400391 109.469429016114 23.3927307128908 -tr {0} {1} -r cubic -overwrite {2} {3}".format(resx, resy,"/home/phamha/Desktop/dem_10km_full.tif","/home/phamha/Desktop/dem_10km_old.tif")
	#regrid_command = "gdalwarp -s_srs '+proj=longlat +datum=WGS84' -t_srs '+proj=longlat +datum=WGS84' -ot Int16 -wt Int16 -te 100.1 6.4 111.8 25.6 -tr {0} {1} -r cubic -overwrite {2} {3}".format(resx, resy,"/home/phamha/Desktop/dem_10km.tif","/home/phamha/Desktop/dem_10km_crop.tif")
	os.system(regrid_command)

	
	
